﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wisery
{
    internal class Character : ViewModelBase
    {
        public Character()
        {
            this.Class = Class.Wizard;
        }

        private int level;
        public int Level
        {
            get { return level; }
            set { this.SetField(ref this.level, value, string.Empty); }
        }

        public Class Class { get; set; }

        private ClassData GetClassData()
        {
            return ClassData.GetData(this.Class); 
        }

        public int BaseInt { get { return this.CalcBaseStat("INT"); } }
        public int BaseDex { get { return this.CalcBaseStat("DEX"); } }
        public int BaseStr { get { return this.CalcBaseStat("STR"); } }
        public int BaseVit { get { return this.CalcBaseStat("VIT"); } }

        private int CalcBaseStat(string stat)
        {
            if (stat == "VIT")
            {
                return 9 + (this.Level - 1)*2;
            }
            else if (stat == this.GetClassData().PrimaryStat)
            {
                return 10 + (this.Level - 1) * 3;
            }
            else
            {
                return 8 + (this.Level - 1);
            }
        }
    }

    public class ClassData
    {
        private ClassData() {}

        public string PrimaryStat { get; private set; }

        public static ClassData GetData(Class c)
        {
            return dataTable[c];
        }

        private static Dictionary<Class, ClassData> dataTable = new Dictionary<Class, ClassData>
        {
            {
                Class.Wizard, 
                new ClassData
                {
                    PrimaryStat = "INT"
                }
            },
        };
    }

    public enum Class
    {
        Barbarian,
        Monk,
        DemonHunter,
        Wizard,
        WitchDoctor
    }
}
